// @Author EthanScriptOn
// @Desc
package log_define

// OutPutType The output types are divided into file output and console output
type OutPutType string

const (
	CONSOLE OutPutType = "CONSOLE"
	FILE    OutPutType = "FILE"
)

// LogSnapshotOutBit The enumeration representation of the template resolution in the log
type LogSnapshotOutBit string

const (
	DATE     LogSnapshotOutBit = "T%"
	LEVEL                      = "L%"
	POSITION                   = "P%"
	MESSAGE                    = "M%"
)

// LogSnapshotDateBit The enumerated representation of the year, month, and day in the log
type LogSnapshotDateBit int

const (
	DAY LogSnapshotDateBit = iota + 1
	MONTH
	YEAR
)

// LogSnapshotDateBitMapping Define mappings, profile-to-log level mappings
var LogSnapshotDateBitMapping = map[string]LogSnapshotDateBit{
	"D%": DAY,
	"M%": MONTH,
	"Y%": YEAR,
}

// PriorityLogSnapshotDateBit Define priority mappings
var PriorityLogSnapshotDateBit = []LogSnapshotDateBit{DAY, MONTH, YEAR}

// LogLevel Log-level enumeration definitions
type LogLevel int

const (
	ALL LogLevel = iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

// PriorityLogLevel Define priority mappings
var PriorityLogLevel = []LogLevel{ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL}

type LogCenterSource string

const (
	CUSTOMER LogCenterSource = "CUSTOMER"
	DEFAULT  LogCenterSource = "DEFAULT"
)

// LogProfile Define the entries for the log
type LogProfile struct {
	Level        int
	Template     string
	Destinations []*LogOutputDestination
	Filters      []*LogFilter
}

// DeepCopy deepCopy
func (l *LogProfile) DeepCopy() *LogProfile {
	destinations := make([]*LogOutputDestination, len(l.Destinations))
	for _, destination := range l.Destinations {
		destinations = append(destinations, destination.DeepCopy())
	}

	filters := make([]*LogFilter, len(l.Destinations))
	for _, filter := range l.Filters {
		filters = append(filters, filter.DeepCopy())
	}
	return &LogProfile{
		Level:        l.Level,
		Template:     l.Template,
		Destinations: destinations,
		Filters:      filters,
	}
}

// LogOutputDestination Define how the logs are output
type LogOutputDestination struct {
	Type              string
	Path              string
	FileNamePattern   string
	MaxFileSize       int
	ValidityRotation  int
	MaxFiles          int
	CustomRotationTag string
}

// DeepCopy deepCopy
func (l *LogOutputDestination) DeepCopy() *LogOutputDestination {
	return &LogOutputDestination{
		Type:              l.Type,
		Path:              l.Path,
		FileNamePattern:   l.FileNamePattern,
		MaxFileSize:       l.MaxFileSize,
		ValidityRotation:  l.ValidityRotation,
		MaxFiles:          l.MaxFiles,
		CustomRotationTag: l.CustomRotationTag,
	}
}

// LogFilter Define filter rules for logs
type LogFilter struct {
	Tag    string
	Active bool
}

// DeepCopy deepCopy
func (l *LogFilter) DeepCopy() *LogFilter {
	return &LogFilter{
		Tag:    l.Tag,
		Active: l.Active,
	}
}
